//
//  LodingView.m
//  Learn
//
//  Created by 迟建国 on 2024/4/6.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "LodingView.h"

@implementation LodingView

+ (LodingView *)lodingWithVc:(UIViewController *)vc Complection:(void(^)(NSString *str))block {
    LodingView *  inputView;
    inputView = [[LodingView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
    [inputView initUI];
    inputView.chooseBlock = block;
    
    NSLog(@"%@", NSObject.getKeyWindowRootViewController);
    [NSObject.getKeyWindowRootViewController gq_presentLikeAlertView:inputView];
    NSObject.getKeyWindowRootViewController.gq_enableBlankDismiss = YES;
    
    return inputView;
}

- (void)initUI {
    UIView *bgView = [[UIView alloc] initWithFrame:self.bounds];
    bgView.backgroundColor = [UIColor blackColor];
    bgView.alpha = 0.75;
    [self addSubview:bgView];
    
    UILabel *messageL = [[UILabel alloc] init];
    messageL.text = @"玩命加载中，请耐心等待…";
    messageL.textColor = UIColor.whiteColor;
    messageL.textAlignment = NSTextAlignmentCenter;
    messageL.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
    [bgView addSubview:messageL];
    [messageL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgView.mas_centerX);
        make.centerY.equalTo(bgView.mas_centerY);

    }];
    
    UIImageView *lodingImageView = [[UIImageView alloc] init];
    lodingImageView.image = [UIImage imageNamed:@"铅笔"];
    [bgView addSubview:lodingImageView];
    [lodingImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgView.mas_centerX);
        make.bottom.equalTo(messageL.mas_top).offset(-20);
        make.width.offset(35);
        make.height.offset(77);
    }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.chooseBlock(@"完成");
}

@end
